package com.zxy.ziems.server.monitor.controller;

import com.zxy.ziems.server.monitor.pojo.dto.MonitorDeviceAddDTO;
import com.zxy.ziems.server.monitor.pojo.dto.MonitorDeviceGroupDTO;
import com.zxy.ziems.server.monitor.pojo.dto.MonitorGroupDeviceDTO;
import com.zxy.ziems.server.monitor.pojo.vo.MonitorDeviceOldVO;
import com.zxy.ziems.server.monitor.pojo.vo.MonitorDeviceVO;
import com.zxy.ziems.server.monitor.service.MonitorGroupDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 监控设备
 *
 * @author chdzq
 * @create 2023/5/25
 */
@RestController
public class MonitorGroupDeviceController {


    /**
     * 修改组监控设备
     *
     * @param monitorDeviceAddDTO
     * @return
     */
    @PostMapping("/api/monitor/updateGroupDevice")
    public boolean updateGroupDevice(@Validated(value = MonitorDeviceAddDTO.Update.class) @RequestBody MonitorDeviceAddDTO monitorDeviceAddDTO) {
        return service.updateGroupDevice(monitorDeviceAddDTO);
    }


    /**
     * 查询本组可分配监控
     *
     * @param monitorDeviceAddDTO
     * @return
     */
    @GetMapping("/api/monitor/groupDevice/listNoByGroupId")
    public List<MonitorDeviceOldVO> listNoByGroupId(@Validated(value = MonitorGroupDeviceDTO.Select.class) MonitorGroupDeviceDTO monitorDeviceAddDTO) {
        return service.listNoByGroupId(monitorDeviceAddDTO.getGroupId());
    }

    /**
     * 根据组id获取监控设备
     *
     * @param monitorDeviceGroupDTO
     * @return
     */
    @GetMapping("/api/monitor/listByGroupId")
    public List<MonitorDeviceVO> getList(@Validated(value = MonitorDeviceGroupDTO.Select.class) MonitorDeviceGroupDTO monitorDeviceGroupDTO) {
        return service.getList(monitorDeviceGroupDTO.getMonitorGroupId());
    }

    private MonitorGroupDeviceService service;

    @Autowired
    public void setService(MonitorGroupDeviceService monitorGroupDeviceService) {
        this.service = monitorGroupDeviceService;
    }
}
